

#ifndef _CONFIG_H_
#define _CONFIG_H_

#include <stdint.h>

/*===================================================================*/

enum cfg_id{
	CFG_ID_MANU = 0,
	CFG_ID_USER,
	CFG_ID_MAX
};

enum {
	CFG_BLK_INFO = 0,
	CFG_BLK_APPLE,
	CFG_BLK_GOOGLE,
	CFG_BLK_LEAF,
	CFG_BLK_MAX
};

#pragma pack(1)

typedef struct {
	uint8_t aid[3];		//密钥对应的 AID
	uint8_t key_id;		//密钥标识
	uint8_t key_ver;	//密钥版本
	uint8_t key_type;	//密钥类型
	uint8_t key_no;		//密钥在卡内的号码
}key_set_t;

typedef struct {
	uint16_t version;		//版本
	uint8_t epc[7];			//EPC
	key_set_t key_sets[2];	//密钥设置
	uint8_t file_id;		//文件ID
	uint16_t offset;		//读取偏移
	uint16_t length;		//读取长度
	uint8_t format;			//格式
}cfg_apple_wallet_t;

typedef struct {
	uint16_t version;		//版本
	key_set_t key_set;		//密钥设置
	uint8_t fid;			//文件ID
	uint8_t df_name[16];	//目录名
}cfg_google_wallet_t;

typedef struct {
	uint32_t magic;			//魔数
	uint32_t check_sum;		//校验和
	uint32_t update_version;		//每更新一次加1
	uint16_t version;		//版本
	uint8_t verify_code[16];
	cfg_apple_wallet_t aw;
	uint8_t reserve1[16];
	cfg_google_wallet_t gw;
	uint8_t reserve2[16];
	uint8_t reserve3[64];
}cfg_wavelynx_t;

#if 0
typedef struct {
	uint8_t magic;
	uint8_t check_sum;
	uint8_t data[62];
}cfg_block_t;


typedef struct {
	cfg_block_t blocks[CFG_BLK_MAX];
}cfg_page_t;
#endif 


#pragma pack()

void cfg_init(void);

cfg_wavelynx_t* cfg_get(uint8_t id);

int cfg_sync(void);

void cfg_clear(uint8_t id);


#endif

